const connection = require("../app/database");

class MomentLikeService{
    async create(moment_id,user_id){
        const statement=`INSERT INTO moment_like (moment_id,user_id) VALUES (?,?);`
        const [result] = await connection.execute(statement, [
            moment_id,
            user_id
          ]);
          return result;
       
    }
    async loveCreate(moment_id,user_id){
        const statement=`UPDATE moment_like SET like_num =like_num+1 WHERE moment_id=?;`
        const [result] = await connection.execute(statement, [
            moment_id
          ]);
          return result;

    }

    async hateCreate(moment_id,user_id){
        const statement=`UPDATE moment_like SET no_like_num =no_like_num+1 WHERE moment_id=?;`
        const [result] = await connection.execute(statement, [
            moment_id
          ]);
          return result;

    }

    
}


module.exports=new MomentLikeService()